package com.example.administrator.projectmoudle_two;

import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.os.PersistableBundle;

import fragment.AnimInterplator;
import fragment.ArgbEvaluatorFragment;
import fragment.BottomSheetFragment;
import fragment.DampListview;
import fragment.DialogFragmentView;
import fragment.GetInitalFragment;
import fragment.ListviewFragment;
import fragment.MesuListView;
import fragment.PopuwindowFragment;
import fragment.RecycleViewDemo;
import fragment.SmootScrollListviewFragment;
import fragment.SortFragment;
import fragment.UsbMontedFragment;
import fragment.VideoViewFragment;
import utils.UsbReceiverUtils;

/**
 * Created by eyesee.
 */

public class ShowFragmentActivity extends Activity {

    private BottomSheetFragment mBottomSheetFragment;
    private GetInitalFragment mGetInitalFragment;
    private ListviewFragment mListviewFragment;
    private VideoViewFragment mVideoViewFragment;
    private SmootScrollListviewFragment mScrollListviewFragment;
    private AnimInterplator mInterplator;
    private DampListview mDampListview;
    private DialogFragmentView mDialogFragmentView;
    private PopuwindowFragment mPopuwindowFragment;
    private MesuListView mMesuListView;
    private RecycleViewDemo mRecycleView;
    private UsbMontedFragment mUsbMonted;
    private SortFragment mSortFragment;
    private ArgbEvaluatorFragment mEvaluatorFragment;

    @Override
    public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
        super.onCreate(savedInstanceState, persistentState);
        setContentView(R.layout.activity_showfragment);

        initFragment();
        UsbReceiverUtils.registUsbReceiver(this);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        UsbReceiverUtils.unregistReceiver(this);
    }

    private void initFragment() {
        mBottomSheetFragment = new BottomSheetFragment();
        mGetInitalFragment = new GetInitalFragment();
        mListviewFragment = new ListviewFragment();
        mVideoViewFragment = new VideoViewFragment();
        mScrollListviewFragment = new SmootScrollListviewFragment();
        mDampListview = new DampListview();
        mInterplator = new AnimInterplator();
        mDialogFragmentView = new DialogFragmentView();
        mPopuwindowFragment = new PopuwindowFragment();
        mMesuListView = MesuListView.getInstance();
        mRecycleView = RecycleViewDemo.getInstance();
        mUsbMonted = new UsbMontedFragment();
        mSortFragment = new SortFragment();
        mEvaluatorFragment = new ArgbEvaluatorFragment();


        //显示
        showFragent(mEvaluatorFragment);
    }

    public void showFragent(Fragment fragment){
        FragmentTransaction transaction = getFragmentManager().beginTransaction();
        transaction.replace(R.id.container,fragment);
        transaction.commit();
    }
}
